package eerbaar.v2.effects.internal;

import java.util.Date;

public class TimeLine {

    private final long startTime = new Date().getTime();

    private final int maxAge;

    private final TimeLineStrategy strategy;

    public TimeLine(int maxAge, Force force, CanvasPosition start) {
        this.strategy = new TimeLineStrategy(force, start);
        this.maxAge = maxAge;
    }

    public CanvasPosition getCanvasPosition() {

        final long current = new Date().getTime();
        final long age = (current - startTime);
        if (age > maxAge) {
            return null;
        }

        return strategy.calc((int) age);
    }

}
